<!-- $Id$ -->
<include file="Public:pageheader"/>
<script type="text/javascript">
function sortBy(order,sort){
	location.href = "?order="+order+"&sort="+sort;
}

var optionAjax = new Object;

/**
 * 创建一个可编辑区
 */
optionAjax.edit = function(obj, act, id) {
	var tag = obj.firstChild.tagName;
	if (typeof(tag) != "undefined" && tag.toLowerCase() == "input") {
		return;
	}
	/* 保存原始的内容 */
	var org = obj.innerHTML;
	var val = Browser.isIE ? obj.innerText : obj.textContent;
	/* 创建一个输入框 */
	var txt = document.createElement("INPUT");
	txt.value = (val == 'N/A') ? '' : val;
	txt.style.width = (obj.offsetWidth + 12) + "px" ;
	/* 隐藏对象中的内容，并将输入框加入到对象中 */
	obj.innerHTML = "";
	obj.appendChild(txt);
	txt.focus();
	/* 编辑区输入事件处理函数 */
	txt.onkeypress = function(e) {
	var evt = Utils.fixEvent(e);
	var obj = Utils.srcElement(e);	
		if (evt.keyCode == 13) {
		  obj.blur();
		  return false;
		}	
		if (evt.keyCode == 27) {
		  obj.parentNode.innerHTML = org;
		}
	}
	/* 编辑区失去焦点的处理函数 */
	txt.onblur = function(e) {
		if (Utils.trim(txt.value).length > 0) {
		   ThinkAjax.send('__URL__/editOption','ajax=1&act='+ act + '&value=' + encodeURIComponent(Utils.trim(txt.value)) + '&id=' + id, complete ,'result');  
		} else {
		  obj.innerHTML = org;
		}
	}
}

function complete(data,status) {
	if (status==1)
	{
		window.location.reload();
	}
}
</script>
<div class="form-div">
<form method="post" action="javascript:newVoteOption()" name="theForm">
    添加投票选项：<input type="text" name="option_name" maxlength="100" size="30"  value=""/>
    <input type="hidden" name="vote_id" value="{$vote_id}" size="30" />
    <input type="submit" value=" 确定 " class="button" />
	&nbsp;&nbsp;&nbsp;&nbsp;<img src="__PUBLIC__/Images/notice.gif" alt="点击此处查看提示信息" border="0" width="16" height="16">&nbsp;&nbsp;带链接地址的选项请用逗号分开. 例如: 选项一,www.yurnero.net<span id="result"></span>
</form>
</div>
<form method="post" action="__URL__/sortOption" name="listForm">
<div class="list-div" id="listDiv">
<table cellpadding="3" cellspacing="1">
<tbody><tr>
     <th><a href="javascript:void(0)" onclick="javascript:sortBy('option_sort','<if condition="$sort eq asc">desc<else/>asc</if>');" title="点击对列表排序">排序</a>
     <if condition="$sort eq asc"><img src="__PUBLIC__/Images/sort_asc.gif"/><else/><img src="__PUBLIC__/Images/sort_desc.gif"/></if></th>
	<th>投票选项</th>
	<th>链接地址</th>   
	<th>票数</th>
	<th>操作</th>
  </tr>
<volist name="list" id="vo">
 <tr>
<td style="background-color: rgb(255, 255, 255);" align="center" class="first-cell"  width="7%"><span><input type="text" name="key[{$vo.option_id}]" size="3" value="{$vo.option_sort}"/></span></td>
<td style="background-color: rgb(255, 255, 255);" align="left" width="43%"><span onclick="optionAjax.edit(this, 'option_name', '{$vo.option_id}')">{$vo.option_name}</span></td>
<td style="background-color: rgb(255, 255, 255);" align="left" width="35%"><span onclick="optionAjax.edit(this, 'option_url', '{$vo.option_id}')">{$vo.option_url|default='N/A'}</span></td>
<td style="background-color: rgb(255, 255, 255);" align="center" width="8%"><span onclick="optionAjax.edit(this, 'option_count', '{$vo.option_id}')">{$vo.option_count}</span></td>
<td style="background-color: rgb(255, 255, 255);" align="center" width="7%">
<a href="__URL__/dropOption/v/{$vo.vote_id}/id/{$vo.option_id}" title="移除" onclick="return confirm('确定删除?');" ><img src="__PUBLIC__/Images/icon_drop.gif" border="0" width="16" height="16"></a></td>
  </tr>
 </volist>
 <tr>
	<td colspan="5"><input value="更新排序" name="btnSubmit" class="button" type="submit" onclick="return confirm('- 必须是一个数字,排序最大255');" ><input type="hidden" name="act" value="do" /><input type="hidden" name="vote_id" value="{$vo.vote_id}" /></td>
      </tr>
</tbody></table>
</div>
</form>
<script language="JavaScript">
<!--
function newVoteOption()
{
  var option_name = Utils.trim(document.forms['theForm'].elements['option_name'].value);
  var id          = Utils.trim(document.forms['theForm'].elements['vote_id'].value);

  if (Utils.trim(option_name).length > 0)
  {
	 ThinkAjax.send('__URL__/newOption','ajax=1&act=send&option_name='+option_name + '&id=' + id, newGoodsTypeResponse ,'result');
  }
  else
  {
	  alert("必须输入调查选项名称!");
  }
}

function newGoodsTypeResponse(data,status)
{
  if (status==1)
  {
    window.location.reload();
  }
}
//-->
</script>
<include file="Public:pagefooter"/>